package com.lrs.java.j2se_self.lastJava;

public class DynamicBinde {
	public static void main(String[] args){
		//System.out.println("Java ,I come back!");
		Dog d = new Dog("狗","白色");
		Cat c = new Cat("猫","蓝色");
		Lady l1 = new Lady("l1",d);
		Lady l2 = new Lady("l2",c);
		l1.petenjoy();
		l2.petenjoy();
	}
}

class Animal {
	public String name ;
	Animal (String name){
		this.name = name ;
	}
	public void enjoy(){
		System.out.println(name+" 高兴了...");
	}
}
class Cat extends Animal{
	private String eyecolor ;
	Cat (String s ,String c){
		super(s);
		eyecolor = c ;
	}
	
	public void enjoy(){
		System.out.println(eyecolor + super.name +"叫了...");
		
	}
}
class Dog extends Animal {
	private String fcolor;
	Dog(String s ,String c){
		super(s);
		fcolor = c ;
	}
	 
	public void enjoy(){
		System.out.println(fcolor+ name+"叫了...");
	}
}
class Lady {
	private String name ;
	private Animal pet;
	Lady(String s, Animal pet){
		this.name = s ;
		this.pet = pet ;
	}
	public void petenjoy(){
		pet.enjoy();
	}
}